<script>
export default {
    data(){
      return{
          dayMap:{
              "01":"1",
              "02":"2",
              "03":"3",
              "04":"4",
              "05":"5",
              "06":"6",
              "07":"7",
              "08":"8",
              "09":"9",
              "10":"A",
              "11":"B",
              "12":"C",
              "13":"D",
              "14":"E",
              "15":"F",
              "16":"G",
              "17":"H",
              "18":"J",
              "19":"K",
              "20":"L",
              "21":"M",
              "22":"N",
              "23":"P",
              "24":"Q",
              "25":"R",
              "26":"S",
              "27":"T",
              "28":"U",
              "29":"X",
              "30":"Y",
              "31":"Z",
          },
          dayMapReversal:{
              "1":"01",
              "2":"02",
              "3":"03",
              "4":"04",
              "5":"05",
              "6":"06",
              "7":"07",
              "8":"08",
              "9":"09",
              "A":"10",
              "B":"11",
              "C":"12",
              "D":"13",
              "E":"14",
              "F":"15",
              "G":"16",
              "H":"17",
              "J":"18",
              "K":"19",
              "L":"20",
              "M":"21",
              "N":"22",
              "P":"23",
              "Q":"24",
              "R":"25",
              "S":"26",
              "T":"27",
              "U":"28",
              "X":"29",
              "Y":"30",
              "Z":"31",
          },
        monthMap:{
              "01":"1",
              "02":"2",
              "03":"3",
              "04":"4",
              "05":"5",
              "06":"6",
              "07":"7",
              "08":"8",
              "09":"9",
              "10":"X",
              "11":"Y",
              "12":"Z",
          },
          monthMapReversal:{
              "1":"01",
              "2":"02",
              "3":"03",
              "4":"04",
              "5":"05",
              "6":"06",
              "7":"07",
              "8":"08",
              "9":"09",
              "X":"10",
              "Y":"11",
              "Z":"12",
          },
      }  
    },
  methods: {
	show(){
		app.utils.showMessage(this.prop);
    }
  },
  watch:{
      "form.made_time"(newVal,oldVal){
          if(newVal != null && newVal.length == 8 && newVal != oldVal){
              let year = newVal.substring(3,4);
              let month = newVal.substring(4,6);
              let day = newVal.substring(6);
              let value = year + this.monthMap[month] + this.dayMap[day];
              this.form.batch_code = value;
          }
      },
      "form.batch_code"(newVal,oldVal){
          if(newVal != null && newVal.length == 3 && newVal != oldVal){
              let year = newVal.substring(0,1);
              let month = newVal.substring(1,2);
              let day = newVal.substring(2);
              if(this.monthMapReversal.hasOwnProperty(month) && this.dayMapReversal.hasOwnProperty(day)){
                  let currentDate = new Date();
                  let currentYear = currentDate.getFullYear();
                  let date = app.utils.formatDate(currentDate,"yyyy");
                  let three = date.substring(0,3);
                  let fullYear = parseInt(three + year);
                  
                  // 如果转换后的年份超过当前年份，则减去10年
                  if(fullYear > currentYear) {
                      fullYear -= 10;
                  }
                  
                  let value = fullYear + "-" + this.monthMapReversal[month] +"-" + this.dayMapReversal[day];
                  this.form.made_time = value;
              }
          }
      },
  }
}
</script>
